<?php
namespace hid\builders;

use \hid\base\IdBuilder;

/**
 * uuid 全局id生成器
 *<B>说明：</B>
 *<pre>
 * 单机唯一性比较好
 *</pre>
 */
class UuidBuilder extends IdBuilder
{

    /**
     * @inheritdoc
     */
    public function getId():string
    {
        return sprintf(
            '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            mt_rand(0, 0xffff), mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0x0fff) | 0x4000,
            mt_rand(0, 0x3fff) | 0x8000,
            mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
        );
    }
}
